#include "junix.h"

int errfn(const char *path,int code);

int main(int argc, char **argv)
{
  glob_t mt;
  int i,ret;
  int flags=0;

  for(i=1;i<argc;i++)
    {
      ret=glob(argv[i],flags, errfn, &mt);
     
      if(ret == GLOB_NOSPACE)
	err_quit("No space");

      flags |= GLOB_APPEND;
    }

  if(!mt.gl_pathc)
    {
      err_quit("No match");
    }
  else 
    {
      for(i=0;i<mt.gl_pathc;i++)
	fprintf(stdout,"%s\n",mt.gl_pathv[i]);
    }

  globfree(&mt);
  exit(0);
}

int errfn(const char *path,int code)
{
  error(code,1,"error access path:%s\n",path);

  return 0;
}
